﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace ResearchId.User
{
    public partial class UserCreate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void wzdCreateUser_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            Response.Redirect("../Default.aspx");
        }

        protected void wzdCreateUser_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            if (CaptchaControl1.UserValidated == false)
            {
                ErrorMessage.Text = "Code entered does not match the picture.";
                e.Cancel = true;
                return;
            }
            if (Individual.UserNameExists(UserName.Text))
            {
                ErrorMessage.Text = "Username already exists. Please choose another.";
                e.Cancel = true;
                return;
            }
            try
            {
                Individual i = Individual.CreateIndividual(UserName.Text, Password.Text);
            }
            catch (Exception err)
            {
                ErrorMessage.Text = err.Message;
                e.Cancel = true;
            }
        }
    }
}
